package org.alexsotob.roo.addon.flyway;

class PersistenceFileModifierFactory {

	private static final String OPENJPA_PERSISTENCE_PROVIDER = "org.apache.openjpa.persistence.PersistenceProviderImpl";
	private static final String ECLIPSE_LINK_PERSISTENCE_PROVIDER = "org.eclipse.persistence.jpa.PersistenceProvider";
	private static final String DATANUCLEUS_PERSISTENCE_PROVIDER = "org.datanucleus.jpa.PersistenceProviderImpl";
	private static final String HIBERNATE_PERSISTENCE_PROVIDER = "org.hibernate.ejb.HibernatePersistence";

	static PersistenceFileModifier create(String persistenceProvider) {
		if (HIBERNATE_PERSISTENCE_PROVIDER
				.equals(persistenceProvider)) {
			return new HibernatePersistenceFileModifier();
		} else if (DATANUCLEUS_PERSISTENCE_PROVIDER
				.equals(persistenceProvider)) {
			return new DataNucleusPersistenceFileModifier();
		} else if (ECLIPSE_LINK_PERSISTENCE_PROVIDER
				.equals(persistenceProvider)) {
			return new EclipseLinkPersistenceFileModifier();
		} else if (OPENJPA_PERSISTENCE_PROVIDER
				.equals(persistenceProvider)) {
			return new OpenJpaPersistenceFileModifier();
		}
		return null;
	}

}
